//client.go
package main
 
import (
	"fmt"
	"net"
    "io/ioutil" 
)
 
//客户端
func main() {
	conn, err := net.Dial("tcp", "119.91.41.185:9504")
	if err != nil {
		fmt.Println("err:", err)
		return
	}
	defer conn.Close() //关闭连接

	for {

		_, err = conn.Write([]byte("EXIT")) //发送数据
		if err != nil {
			return
		}
		buf := [512]byte{}
		n, err := conn.Read(buf[:])
		if err != nil {
			fmt.Println("recv failed,err:", err)
			return
		}

        logs:=string(buf[:n]);
        
		fmt.Println(logs)
		
		var d1 = []byte(logs)
        ioutil.WriteFile("SYS_RUN.TXT", d1, 0777) //写入文件(字节数组)
		
	}
}
